﻿using ControlHelper.Attributes;
using Creator.Core.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace DesktopCreator.ViewModel
{
    public class BaseObjectViewModel:ViewModelBase
    {
          
        public BaseObjectViewModel(BaseObject @object)
        {
            Object = @object;
        }
        public BaseObject Object { get; set; }

        public bool Active
        {
            get => Object.Active; set
            {
                Object.Active = value; 
                ActiveColor = value ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(Colors.Gray);
                OnPropertyChanged();
            }
        }

        public string Name
        {
            get => Object.Name; set { Object.Name = value; OnPropertyChanged(); }

        }

        public bool IsPorcessObj => Object is ProcessObject ;

        public Visibility DetailVis
        {
            get
            {
                return IsPorcessObj ? Visibility.Visible : Visibility.Collapsed;
            }
        }
        public bool IsShow
        {
            get
            {
                if (!IsPorcessObj) return false;
                return (Object as ProcessObject).IsShow;
            }
            set
            {
                if (!IsPorcessObj) return;
                (Object as ProcessObject).IsShow = value;
                OnPropertyChanged();
            }
        }
        public bool IsSingleThread
        {
            get
            {
                if (!IsPorcessObj) return false;
                return (Object as ProcessObject).IsSingleThread;
            }
            set
            {
                if (!IsPorcessObj) return;
                (Object as ProcessObject).IsSingleThread = value;
                OnPropertyChanged();
            }
        } 

        public string Position { get => Object.Position;  }

        private Brush activeColor = new SolidColorBrush(Colors.Black);
        public Brush ActiveColor
        {
            get => activeColor; set
            {
                activeColor = value;
                OnPropertyChanged();
            }
        } 
    }
}
